import { Component, OnInit } from '@angular/core';
import {AdminService} from "../../../../services/admin.service";
import {AlertService} from "../../../../services/alert.service";
import {HostService} from "../../../../services/host.service";

@Component({
  selector: 'app-gotoadmin',
  templateUrl: './gotoadmin.component.html',
  styleUrls: ['./gotoadmin.component.css']
})
export class GotoadminComponent implements OnInit {
  ticket:string
  constructor(private adminService:AdminService,
              private alertService:AlertService,
              private hostService:HostService) { }

  ngOnInit(): void {
this.alertService.showWarning("请确保本站允许弹开窗口，否则权限系统无法显示")
 this.gotoAuthcenter()
  }
  gotoAuthcenter() {
    this.adminService.getTicket().then((data: any) => {
      if (data.msg == "ok") {
        this.ticket = data.obj
        window.open(this.hostService.AuthHOST+"/login?ticket="+this.ticket)
      }else{
        this.alertService.showError("参数异常请重试")
      }
    })
  }
}
